<!--
  - Copyright 2011 Angel Sanadinov
  -
  - This file is part of VBox WMI.
  -
  - VBox WMI is free software: you can redistribute it and/or modify
  - it under the terms of the GNU General Public License as published by
  - the Free Software Foundation, either version 3 of the License, or
  - (at your option) any later version.
  -
  - VBox WMI is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  - GNU General Public License for more details.
  -
  - You should have received a copy of the GNU General Public License
  - along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
  -->

<%@tag import="Beans.Responses.DataRetrievalComponents.SystemDataComponent"%>
<%@tag import="Beans.Responses.DataRetrievalResponse"%>
<%@tag import="Utilities.Constants.ResourceRequestType"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="jstlc" %>
<%@tag description="Prints system data." pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>

<%-- Attributes --%>
<%@attribute name="data" required="true" description="System data retrieval response."
             rtexprvalue="true" type="DataRetrievalResponse<SystemDataComponent>"%>
<%-- End of Attributes --%>

<%-- Page Body Content --%>
<jstlc:choose>
    <jstlc:when test="${data == null}">
        Failed to retrieve system data object.
    </jstlc:when>

    <jstlc:when test="${data.requestResult && data.valid}">
        <jstlc:choose>
            <jstlc:when test="<%= data.getResourceRequestType() == ResourceRequestType.SINGLE_RESOURCE %>">
                <jstlc:set var="system" value="${data.resource}"/>
                <table id="mainSystemTable" class="mainResourceDataTable">
                <tr><td>Server Id:</td><td>${system.serverId}</td>
                    <td><a  class="actionLink" href="servers.jsp?id=${system.serverId}">View</a></td></tr>
                <tr><td>Version:</td><td>${system.virtualBoxData.version}</td></tr>
                <tr><td>Revision:</td><td>${system.virtualBoxData.revision}</td></tr>
                <tr><td>Package Type:</td><td>${system.virtualBoxData.packageType}</td></tr>
                <tr><td>Home Folder:</td><td>${system.virtualBoxData.homeFolder}</td></tr>
                <tr><td>Settings File:</td><td>${system.virtualBoxData.settingsFile}</td></tr>
                </table>
                <div id="additionalInfo">
                    <a class="operationsLink" href="noJavaScript.jst" onclick="return changePopupVisibility('additionalInfoConstraints');">Guest Constraints</a><br>
                    <a class="operationsLink" href="noJavaScript.jst" onclick="return changePopupVisibility('additionalInfoDefaults');">Defaults</a><br>
                    <a class="operationsLink" href="noJavaScript.jst" onclick="return changePopupVisibility('additionalInfoWarnings');">Warnings</a><br>
                    <a class="operationsLink" href="noJavaScript.jst" onclick="return changePopupVisibility('additionalInfoOther');">Miscellaneous</a><br>
                    <a class="operationsLink" href="noJavaScript.jst" onclick="return changePopupVisibility('processorsData');">Processors Data</a><br>
                    <a class="operationsLink" href="noJavaScript.jst" onclick="return changePopupVisibility('hostDataTable');">Host System Data</a><br>
                    <a class="operationsLink" href="noJavaScript.jst" onclick="return changePopupVisibility('storageBusConstraintsTable');">Storage Bus Constraints</a><br>
                    <a class="operationsLink" href="noJavaScript.jst" onclick="return changePopupVisibility('supportedMediumFormatsTable');">Supported Medium Formats</a><br>
                </div>
                <table id="additionalInfoConstraints" class="resourceDataTable">
                <tr><td>Min RAM Size:</td><td>${system.virtualBoxData.minRAMSize} MB</td></tr>
                <tr><td>Max RAM Size:</td><td>${system.virtualBoxData.maxRAMSize} MB</td></tr>
                <tr><td>Min VRAM Size:</td><td>${system.virtualBoxData.minVRAMSize} MB</td></tr>
                <tr><td>Max VRAM Size:</td><td>${system.virtualBoxData.maxVRAMSize} MB</td></tr>
                <tr><td>Min CPU Count:</td><td>${system.virtualBoxData.minCPUCount}</td></tr>
                <tr><td>Max CPU Count:</td><td>${system.virtualBoxData.maxCPUCount}</td></tr>
                <tr><td>Max Monitors:</td><td>${system.virtualBoxData.maxMonitors}</td></tr>
                <tr><td>Max VDI Size:</td><td>${system.virtualBoxData.maxVDISize} MB</td></tr>
                <tr><td>Network Adapters:</td><td>${system.virtualBoxData.numberOfNetworkAdapters} (per VM)</td></tr>
                <tr><td>Serial Ports:</td><td>${system.virtualBoxData.numberOfSerialPorts} (per VM)</td></tr>
                <tr><td>Parallel Ports:</td><td>${system.virtualBoxData.numberOfParallelPorts} (per VM)</td></tr>
                <tr><td>Max Boot Position:</td><td>${system.virtualBoxData.maxBootPosition}</td></tr>
                </table>
                <table id="additionalInfoDefaults" class="resourceDataTable">
                <tr><td>Machines Folder:</td><td>${system.virtualBoxData.defaultMachinesFolder}</td></tr>
                <tr><td>Hard Disks Folder:</td><td>${system.virtualBoxData.defaultHardDisksFolder}</td></tr>
                <tr><td>Hard Disks Format:</td><td>${system.virtualBoxData.defaultHardDiskFormat}</td></tr>
                <tr><td>Audio Driver:</td><td>${system.virtualBoxData.defaultAudioDriver}</td></tr>
                </table>
                <table id="additionalInfoWarnings" class="resourceDataTable">
                <tr><td>Free Disk Space Warning:</td><td>${system.virtualBoxData.freeDiskSpaceWarning} MB</td></tr>
                <tr><td>Free Disk Space Warning:</td><td>${system.virtualBoxData.freeDiskSpaceWarningPercent}%</td></tr>
                <tr><td>Free Disk Space Error:</td><td>${system.virtualBoxData.freeDiskSpaceError} MB</td></tr>
                <tr><td>Free Disk Space Error:</td><td>${system.virtualBoxData.freeDiskSpaceErrorPercent}%</td></tr>
                </table>
                <table id="additionalInfoOther" class="resourceDataTable">
                <tr><td>VRDP Auth Library:</td><td>${system.virtualBoxData.VRDPAuthenticationLibrary}</td></tr>
                <tr><td>WS Auth Library:</td><td>${system.virtualBoxData.webServiceAuthenticationLibrary}</td></tr>
                <tr><td>Log History Count:</td><td>${system.virtualBoxData.logHistoryCount}</td></tr>
                </table>
                <table id="supportedMediumFormatsTable" class="resourceDataTable">
                    <tr><td>ID</td><td>Name</td><td>Capabilities</td></tr>
                    <jstlc:forEach var="format" items="${system.virtualBoxData.supportedMediumFormats}">
                        <tr><td>${format.id}</td><td>${format.name}</td><td>${format.capabilities}</td></tr>
                    </jstlc:forEach>
                </table>
                <table id="storageBusConstraintsTable" class="resourceDataTable">
                    <tr><td>Storage Bus</td><td>Ports</td><td>Slots</td><td>Max Instances</td></tr>
                    <jstlc:forEach var="constraint" items="${system.virtualBoxData.busConstraints}">
                        <tr><td>${constraint.key}</td><td>${constraint.value.maxPortCount}</td>
                            <td>${constraint.value.maxDevicesPerPort}</td><td>${constraint.value.maxNumberOfBusInstances}</td></tr>
                    </jstlc:forEach>
                </table>
                <table id="hostDataTable" class="resourceDataTable">
                <tr><td>Processors Count:</td><td>${system.hostData.processorsCount}</td></tr>
                <tr><td>Online Proc. Count:</td><td>${system.hostData.onlineProcessorsCount}</td></tr>
                <tr><td>Cores Count:</td><td>${system.hostData.processorCoresCount}</td></tr>
                <tr><td>Memory Size:</td><td>${system.hostData.memorySize} MB</td></tr>
                <tr><td>Avail. Memory:</td><td>${system.hostData.availableMemory} MB</td></tr>
                <tr><td>Operating System:</td><td>${system.hostData.operatingSystem}</td></tr>
                <tr><td>OS Version:</td><td>${system.hostData.operatingSystemVersion}</td></tr>
                <tr><td>Host Time:</td><td> ${system.hostData.UTCTime}</td></tr>
                <tr><td>3D Acceleration:</td><td>${system.hostData.acceleration3DAvailable ? "Available" : "Not Available"}</td></tr>
                </table>
                <div id="processorsData" class="resourceDataTable">
                <table id="processorsDataTable">
                <tr><td>Processor #</td><td>Speed</td><td>Description</td></tr>
                <jstlc:set var="descriptions" value="${system.hostData.processorDescriptions}"/>
                <jstlc:forEach varStatus="loop" var="speed" items="${system.hostData.processorSpeeds}">
                    <tr><td>${loop.index}</td><td>${speed}</td><td>${descriptions[loop.index]}</td></tr>
                </jstlc:forEach>
                </table>
                ---------------------------
                <table id="processorFeaturesTable">
                    <tr><td>Feature</td><td>Supported</td></tr>
                    <jstlc:forEach var="feature" items="${system.hostData.processorFeatures}">
                        <tr><td>${feature.key}</td><td>${feature.value ? "Yes" : "No"}</td></tr>
                    </jstlc:forEach>
                </table>
                </div>
            </jstlc:when>

            <jstlc:otherwise>
                Invalid resource request type: ${data.resourceRequestType}.
            </jstlc:otherwise>
        </jstlc:choose>
    </jstlc:when>

    <jstlc:otherwise>
        Error: ${data.exception.exceptionMessage}
    </jstlc:otherwise>
</jstlc:choose>
<%-- End of Page Body Content --%>